package nz.ac.vuw.ecs.kcassell.geometry;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
 * A point class that implements the Shape interface.
 * @author Keith Cassell
 */
public class PointShape implements Shape {
	
	public Point shape = null;
	
	public PointShape(Point point) {
		shape = point;
	}

	public boolean contains(Point2D p) {
		return shape.equals(p);
	}

	/** We assume a point can not contain a rectangle */
	public boolean contains(Rectangle2D r) {
		return false;
	}

	public boolean contains(double x, double y) {
		double shapeX = shape.getX();
		double shapeY = shape.getY();
		return (x == shapeX) && (y == shapeY);
	}

	/** We assume a point can not contain a rectangle */
	public boolean contains(double x, double y, double w, double h) {
		return false;
	}

	public Rectangle getBounds() {
		Rectangle rect = new Rectangle(shape);
		return rect;
	}

	public Rectangle2D getBounds2D() {
		return getBounds();
	}

	/** Nothing to iterate on. */
	public PathIterator getPathIterator(AffineTransform at) {
		return null;
	}

	/** Nothing to iterate on. */
	public PathIterator getPathIterator(AffineTransform at, double flatness) {
		return null;
	}

	public boolean intersects(Rectangle2D r) {
		return r.contains(shape);
	}

	public boolean intersects(double x, double y, double w, double h) {
		Rectangle rect = new Rectangle(shape, new Dimension((int)w, (int)h));
		return rect.contains(shape);
	}

}
